package com.yanshaohui.controller;

import com.yanshaohui.bean.Person;
import com.yanshaohui.feign.ProviderBoot;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by TS-Ysh on 2018-05-16.
 */
@RestController
@RequestMapping("feign/mvc")
public class FeignTestController {

    @Autowired
    private ProviderBoot providerBoot;

    @GetMapping("/person/{id}")
    public Person getOnePerson(@PathVariable("id") Long id){
        return providerBoot.getOnePerson(id);
    }

    @GetMapping("/persons")
    public List<Person> getAllPerson(){
        return providerBoot.getAllPerson();
    }

    /**
     * 提供者内部有延迟的版本
     * @param id
     * @return
     */
    @GetMapping("/person2/{id}")
    public Person getOnePerson2(@PathVariable("id") Long id){
        return providerBoot.getOnePerson2(id);
    }
}
